import { StyleSheet, Text, View, Image } from 'react-native'
import Icon from 'react-native-vector-icons/FontAwesome'
import EntypoIcon from 'react-native-vector-icons/Entypo'
import React, { useState } from 'react'

const AttentionGuanzhu = (props) => {
  const [zan, setZan] = useState(false) // 点赞的状态
  const [num, setNum] = useState(0)
  const { data } = props
  return (
    <View style={styles.container}>
      {/* 头像，个人资料 */}
      <View style={styles.header}>
        <Image source={data.uPhoto} style={styles.headerImg} />
        <View style={styles.nameTime}>
          <Text style={styles.name}>{data.nickName}</Text>
          <Text style={styles.time}>{data.time}</Text>
        </View>
      </View>
      {/* 内容区域 */}
      <View>
        <Text style={styles.textContent}>{data.content}</Text>
      </View>
      {/* 帖子图片 */}
      <View>
        <Image source={data.imgContent} style={styles.contentImg} />
      </View>
      {/* 点赞评论 */}
      <View style={styles.iconCount}>
        <View style={styles.zanCount}>
          <View style={styles.iconText}>
            <Icon style={zan && num == data.id ? [styles.iconZan, { color: '#2a7cff' }] : styles.iconZan} name='thumbs-o-up' size={20} onPress={() => {
              setNum(data.id)
              setZan(!zan)
            }} />
            <Text style={zan && num == data.id ? [styles.textZan, { color: '#2a7cff' }] : styles.textZan}>{data.zanCount}</Text>
          </View>
          <View style={styles.iconText}>
            <Icon style={styles.iconZan} name='commenting-o' size={20} />
            <Text style={styles.textZan}>{data.msg}</Text>
          </View>
        </View>
        <EntypoIcon name='dots-three-horizontal' size={20} />
      </View>
      {/* 评论区 */}
      <View>
        {data.leaveWord.map(item => {
          return (
            <Text style={styles.comments}  numberOfLines={2} ellipsizeMode={'tail'} key={item.lid}>
              <Text style={styles.commentsName}>{item.luNickName}: </Text>
              <Text style={styles.commentsContent}>{item.lmsg}</Text>
            </Text>
          )
        })}
      </View>
    </View>
  )
}

export default AttentionGuanzhu

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    padding: 20,
    marginBottom: 10
  },
  header: {
    display: 'flex',
    flexDirection: 'row',
    alignItems: 'center'
  },
  headerImg: {
    width: 50,
    height: 50,
    borderRadius: 25,
    marginRight: 20
  },
  nameTime: {

  },
  name: {
    fontSize: 20,
    color:'#000',
    fontWeight: 'bold',
  },
  time: {
    fontSize: 14,
    color: '#999',
    fontWeight: 'bold',
    marginTop: 5
  },
  textContent: {
    fontSize: 17,
    fontWeight: '400',
    color: '#000',
    marginTop: 10,
    marginBottom: 10,
  },
  contentImg: {
    width: 100,
    height: 100
  },
  iconCount: {
    display: 'flex',
    flexDirection: 'row',
    // backgroundColor: '#eee',
    justifyContent: 'space-between',
    alignItems: 'center',
    borderBottomWidth: 2,
    borderBottomColor: '#eee'
  },
  zanCount: {
    display: 'flex',
    flexDirection: 'row',
    marginTop: 20,
    marginBottom: 20
  },
  iconText: {
    display: 'flex',
    flexDirection: 'row',
    marginRight: 20
  },
  iconZan: {
    marginRight: 10
  },
  comments: {
    // textAlign:'center'
  },
  commentsName: {
    fontSize: 18,
    color: '#000'
  },
  commentsContent: {
    fontSize: 15,
    color: '#999'
  }
})